<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>model</title>
	<meta http-equiv="Content-language" content="zh-CN" />
	<style type="text/css" media="all">
	</style>
<script type="text/javascript">
//<![CDATA[
(function(){
 var cache = {};
 this.tmpl = function tmpl(str, data){
 // Figure out if we're getting a template, or if we need to
 // load the template - and be sure to cache the result.
 var fn = !/\W/.test(str) ?
 cache[str] = cache[str] ||
 tmpl(document.getElementById(str).innerHTML) :

 // Generate a reusable function that will serve as a template
 // generator (and which will be cached).
 new Function("obj",
	 "var p=[],print=function(){p.push.apply(p,arguments);};" +

	 // Introduce the data as local variables using with(){}
	 "with(obj){p.push('" +

	 // Convert the template into pure JavaScript
	 str
	 .replace(/&gt;/g, ">")
	 .replace(/&lt;/g, "<")
	 .replace(/[\r\t\n]/g, " ")
	 .split("<%").join("\t")
	 .replace(/((^|%>)[^\t]*)'/g, "$1\r")
	 .replace(/\t=(.*?)%>/g, "',$1,'")
	 .split("\t").join("');")
	 .split("%>").join("p.push('")
	 .split("\r").join("\\'")
	 + "');}return p.join('');");
// Provide some basic currying to the user
return data ? fn( data ) : fn;
 };
})(); 
//]]>
</script>
</head>
<body>
<div id="page">
<div id="results"></div>
<div style="display:none;" id="user_tmpl">
<% for ( var i = 0; i < users.length; i++ ) { %>
	<li><a href="<%=users[i].url%>"><%=users[i].name%></a></li>
<% } %>
</div>
<script type="text/javascript">
//<![CDATA[
var results = document.getElementById("results");
var users = [
	{'name':'baidu', 'url':'http://www.baidu.com'},
	{'name':'google', 'url':'http://www.google.com'},
];
results.innerHTML = tmpl("user_tmpl", users);
document.getElementById('user_tmpl').parentNode.removeChild(document.getElementById('user_tmpl'));
//]]>
</script>
</div><!-- #page end! -->
</script>
</body>
</html>
